#ifndef __QUOTATION_GUI_H__
#define __QUOTATION_GUI_H__

#include <string>
//#include <afxwin.h>
#include <map>
#include "IOptionsControl.h"
#include "GridGui.h"
#include "ISysResources.h"

const int  QUOTAT_WIDTH  = 195;
const int  QUOTAT_HEIGHT = 317;
const int  QUOTATION_TOP  = 10;
const int  QUOTATION_LEFT = 4;
const int  QUOTAT_INDEX_TOP = QUOTATION_TOP;
const int  QUOTAT_INDEX_BOTTOM = QUOTATION_TOP + 84;
const int  QUOTAT_ASK_TOP = QUOTAT_INDEX_BOTTOM;
const int  QUOTAT_ASK_BOTTOM = QUOTATION_TOP + 189;
const int  QUOTAT_BID_TOP = QUOTAT_ASK_BOTTOM + 1;
const int  QUOTAT_BID_BOTTOM = QUOTAT_HEIGHT;
const int  FIXED_ROW_COUNT = 4;
const int  SPACE_WIDTH    = 1;
const int  CAPTION_WIDTH  = 28;
const int  PRICE_WIDTH    = 69;
const int  VOLUME_WIDTH   = 78;
const int  HEIGHT         = 21;
const int  FONT_SIZE      = 22;
const int  MIDE_X         = 193;
const int  MIDE_Y         = 204;
const int  LIMT_Y         = 475;
const int  CANVAS_HEIGHT  = 317;
const COLORREF HIGH_LIGHT_COLOR = 0xd48141;

class CQuotationGui : public virtual IQuotationGui, public virtual IProductInstance
{
INIT_CLASS_PRODUCT(CQuotationGui)
public:
	const bool Init(const void * pvdPara, char * pszMsgTxt, int iMsgTxtSize);
	const void UnInit();
	void SetCanvas(::HWND ptrHwndImg = NULL);	
	void DrawIndex(const char * pszName, const char * pszValue, int iDir, const double dClosePrice); 	
	void Draw();
	const bool Refresh(const int iType);
	const void ChangeSkin(bool bColorFlg = false);
	void SetContract(IContract * ptrContract);
	::BOOL OnMouseWheel(UINT nFlags, short zDelta);
	void OnButtonUp(int iAtX, int iAtY);
	void OnMouseMove(int iAtX, int iAtY);
	void OnPaint();

private:
	COLORREF GetColor(int iType, int iComVal = -2, ::RECT * ptrCellInfo = NULL);
	void InitGridUi(int iTop, int iLeft, int iSpace, int iFontSize, int iCaptionWidth, int iPriceWidth, int iHeight, int iVolWidth);
	const int CompareValue(const double dNum1, const double dNum2);
	bool IsEffectiveArea(::HWND ptrHwndForm, int iAtX, int iAtY);
	bool GetCellInfo(int iRow, int iCol, ST_CELL_INFO & StCellInfo);
	bool _Select(int iRow, const double dClosePrice, bool bColorFlg);
	const bool _Refresh(const int iType);
	bool Click(int iAtX, int iAtY);
	bool Select(int iAtX, int iAtY, const double dClosePrice, bool bColorFlg);
	bool Select(int iRow, const double dClosePrice, bool bColorFlg);
	const int GetRow() { return m_iRow; }
	const void SetRow(const int iRow) { m_iRow = iRow; }

private:
	CGridGui * m_ptrCanvas;
	::HWND m_HwndQuotation;
	RECT m_clCanvasRect;
	map<string, string> m_mpCaption;
	int m_iRow, m_iX, m_iY;
	bool m_bColorFlg;
	ILock * m_ptrLock;
	IContract * m_ptrContract;
	double m_dClosePrice;
};

#endif//__QUOTATION_GUI_H__